import numpy as np
H = -(6/10)*np.log2(6/10)-(4/10)*np.log2(4/10)
print(H)

H1 = -(10/10)*np.log2(10/10)
print(H1)
H2 = -(1/10)*np.log2(1/10)-(9/10)*np.log2(9/10)
print(H2)
H3 = -(3/10)*np.log2(3/10)-(4/10)*np.log2(4/10)-(3/10)*np.log2(3/10)
print(H3)

#是否胎生
#信息增益
#entroy(前)
E = -(8/14)*np.log2(8/14)-(6/14)*np.log2(6/14)
#entroy(后)
e1 = -(7/7)*np.log2(7/7)
e2 = -(1/7)*np.log2(1/7)-(6/7)*np.log2(6/7)
#信息增益
G=E-(7/14)*(e1)-(7/14)*(e2)
print(G)
#信息增益比
H6 = 1/(-(7/14)*np.log2(7/14)-(7/14)*np.log2(7/14))
Gr=G*H6
print(Gr)

#饮食习性
#信息增益
E = -(8/14)*np.log2(8/14)-(6/14)*np.log2(6/14)
e1 = -(3/8)*np.log2(3/8)-(5/8)*np.log2(5/8)
e2 = -(3/4)*np.log2(3/4)-(1/4)*np.log2(1/4)
e3 = -(2/2)*np.log2(2/2)
G=E - (8/14)*(e1)-(4/14)*(e2)-(2/14)*(e3)
print(G)
#信息增益比
H7 = (-(8/14)*np.log2(8/14)-(2/14)*np.log2(2/14)-(4/14)*np.log2(4/14))
Gr=G/H7
print(Gr)

